<?php


defined('G_IN_SYSTEM') or exit('No permission resources.');
define('MEMBER', true);

class base extends SystemAction
{
    protected $userinfo = null;
    public function __construct()
    {
        if (ROUTE_M == 'member' && ROUTE_C == 'user' && ROUTE_A == 'login') {
            return;
        }
        if (ROUTE_M == 'member' && ROUTE_C == 'user' && ROUTE_A == 'register') {
            return;
        }
  
        $uid = intval(_getsession('user_id'));
        $utype = _encrypt(_getsession('utype'), 'DECODE');
        $ushell = _encrypt(_getsession('ushell'), 'DECODE');

        if ($utype === null) {
            $this->HeaderLogin();
        }
        if (!$uid) {
            $this->HeaderLogin();
        }
        $this->userinfo = $this->DB()->GetOne("SELECT * from `@#_member` where `uid` = '$uid'");
        if (!$this->userinfo) {
            $this->HeaderLogin();
        }

        $shell = md5($this->userinfo['id'].$this->userinfo['password'].$this->userinfo[$utype]);
        if ($ushell != $shell) {
            $this->HeaderLogin();
        }
    }

    private function HeaderLogin()
    {
        _message('�㻹δ��¼����Ȩ�޷��ʸ�ҳ��', WEB_PATH.'/member/user/login', 3);
    }
}
